package com.leisurexi.aop.features;

import com.leisurexi.aop.features.aspect.AspectConfig;
import com.leisurexi.aop.features.aspect.AspectConfig2;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * @author: leisurexi
 * @date: 2021-05-21 15:03
 */
@Configuration
@EnableAspectJAutoProxy // 激活 Aspect 注解自动代理
public class AspectJAnnotationPointcutDemo {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(AspectJAnnotationPointcutDemo.class, AspectConfig.class, AspectConfig2.class);
        context.refresh();

        AspectJAnnotationPointcutDemo aspectJAnnotationDemo = context.getBean(AspectJAnnotationPointcutDemo.class);
        aspectJAnnotationDemo.execute();

        context.close();
    }

    public void execute() {
        System.out.println("execute()...");
    }

}
